package factor1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-08-20
 * Time: 16:24
 */
public class ProxyUser {
    private User user;
    public ProxyUser(User user) {
        this.user = user;
    }

    public void disPlay() {
        this.user.display();
    }
    public void addBook(String nameBook) {
        if(this.user instanceof AdminUser) {
            ((AdminUser)this.user).addBook(nameBook);
        }else if(this.user instanceof NormalUser) {
            System.out.println("普通用户没有添加图书的权限");
        }
    }
    public void borrowBook(String nameBook) {
        if(this.user instanceof NormalUser) {
            ((NormalUser)this.user).borrowBook(nameBook);
        }else if(this.user instanceof AdminUser) {
            System.out.println("管理员没有借阅图书的权限");
        }
    }
}
